/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Form.java
 *
 * Created on 15-lug-2010, 19.28.53
 */

package GUI;
import calcolatrice.*;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;

/**
 *
 * @author Gabryz
 */
public class Calcolatrice extends javax.swing.JFrame {
    
    private Calcolatore calc;

    @Override
    public void paint(Graphics g) {
        //Toolkit toolkit = Toolkit.getDefaultToolkit();
        //Image image = toolkit.getImage("numeri.gif");
        
        super.paint(g);
        //g.drawImage(image, 0, 0,240 , 240, rootPane);
    }

    /** Creates new form Form */
    public Calcolatrice() {
        initComponents();
        calc=new Calcolatore();
        CalcoloNormale();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    protected enum Type{
        NORMALE,INTEGRALE,DERIVATA;
    }
    Type type=Type.NORMALE;
    
    public Type getType(){
        return type;
    }
    public void setType(Type t){
        this.type=t;
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        _menoButton = new javax.swing.JButton();
        _virgButton = new javax.swing.JButton();
        _costButton = new javax.swing.JButton();
        _piuButton = new javax.swing.JButton();
        _xButton = new javax.swing.JButton();
        _elevateButton = new javax.swing.JButton();
        _0Button = new javax.swing.JButton();
        _8Button = new javax.swing.JButton();
        _9Button = new javax.swing.JButton();
        _pigrecoButton = new javax.swing.JButton();
        _6Button = new javax.swing.JButton();
        _7Button = new javax.swing.JButton();
        _divButton = new javax.swing.JButton();
        _perButton = new javax.swing.JButton();
        _Derivata = new javax.swing.JRadioButton();
        _Integrale = new javax.swing.JRadioButton();
        _Normale = new javax.swing.JRadioButton();
        _calcolaButton = new javax.swing.JButton();
        _parButton = new javax.swing.JButton();
        _parclosedButton = new javax.swing.JButton();
        _sinButton = new javax.swing.JButton();
        _cosButton = new javax.swing.JButton();
        _tgButton = new javax.swing.JButton();
        _cotgButton = new javax.swing.JButton();
        _logButton = new javax.swing.JButton();
        _5Button = new javax.swing.JButton();
        _expButton = new javax.swing.JButton();
        _2Button = new javax.swing.JButton();
        _1Button = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        _TextBox = new javax.swing.JTextArea();
        _4Button = new javax.swing.JButton();
        _3Button = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setForeground(java.awt.Color.white);

        _menoButton.setText("-");
        _menoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _menoButtonActionPerformed(evt);
            }
        });

        _virgButton.setText(",");
        _virgButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _virgButtonActionPerformed(evt);
            }
        });

        _costButton.setText("cost");
        _costButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _costButtonActionPerformed(evt);
            }
        });

        _piuButton.setText("+");
        _piuButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _piuButtonActionPerformed(evt);
            }
        });

        _xButton.setText("x");
        _xButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _xButtonActionPerformed(evt);
            }
        });

        _elevateButton.setText("^");
        _elevateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _elevateButtonActionPerformed(evt);
            }
        });

        _0Button.setText("0");
        _0Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _0ButtonActionPerformed(evt);
            }
        });

        _8Button.setText("8");
        _8Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _8ButtonActionPerformed(evt);
            }
        });

        _9Button.setText("9");
        _9Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _9ButtonActionPerformed(evt);
            }
        });

        _pigrecoButton.setFont(new java.awt.Font("Symbol", 0, 11));
        _pigrecoButton.setText("");
        _pigrecoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _pigrecoButtonActionPerformed(evt);
            }
        });

        _6Button.setText("6");
        _6Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _6ButtonActionPerformed(evt);
            }
        });

        _7Button.setText("7");
        _7Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _7ButtonActionPerformed(evt);
            }
        });

        _divButton.setText("/");
        _divButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _divButtonActionPerformed(evt);
            }
        });

        _perButton.setText("*");
        _perButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _perButtonActionPerformed(evt);
            }
        });

        buttonGroup1.add(_Derivata);
        _Derivata.setText("Derivata");
        _Derivata.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _DerivataActionPerformed(evt);
            }
        });

        buttonGroup1.add(_Integrale);
        _Integrale.setText("Integrale");
        _Integrale.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _IntegraleActionPerformed(evt);
            }
        });

        buttonGroup1.add(_Normale);
        _Normale.setSelected(true);
        _Normale.setText("Normale");
        _Normale.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _NormaleActionPerformed(evt);
            }
        });

        _calcolaButton.setText("Calcola");
        _calcolaButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _calcolaButtonActionPerformed(evt);
            }
        });

        _parButton.setText("(");
        _parButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _parButtonActionPerformed(evt);
            }
        });

        _parclosedButton.setText(")");
        _parclosedButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _parclosedButtonActionPerformed(evt);
            }
        });

        _sinButton.setText("sin");
        _sinButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _sinButtonActionPerformed(evt);
            }
        });

        _cosButton.setText("cos");
        _cosButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _cosButtonActionPerformed(evt);
            }
        });

        _tgButton.setText("tg");
        _tgButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _tgButtonActionPerformed(evt);
            }
        });

        _cotgButton.setText("cotg");
        _cotgButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _cotgButtonActionPerformed(evt);
            }
        });

        _logButton.setText("log");
        _logButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _logButtonActionPerformed(evt);
            }
        });

        _5Button.setText("5");
        _5Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _5ButtonActionPerformed(evt);
            }
        });

        _expButton.setText("exp");
        _expButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _expButtonActionPerformed(evt);
            }
        });

        _2Button.setText("2");
        _2Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _2ButtonActionPerformed(evt);
            }
        });

        _1Button.setText("1");
        _1Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _1ButtonActionPerformed(evt);
            }
        });

        jScrollPane1.setAutoscrolls(true);

        _TextBox.setColumns(20);
        _TextBox.setRows(2);
        _TextBox.setAutoscrolls(false);
        jScrollPane1.setViewportView(_TextBox);

        _4Button.setText("4");
        _4Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _4ButtonActionPerformed(evt);
            }
        });

        _3Button.setText("3");
        _3Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _3ButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 438, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(_Normale)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(_Integrale)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(_Derivata)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(_calcolaButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(_4Button)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(_5Button)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(_6Button))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(_1Button)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(_2Button)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(_3Button))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(_7Button)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(_8Button))
                                            .addComponent(_0Button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(_virgButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(_9Button))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(_divButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(_perButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(_menoButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(_piuButton, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(_expButton, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
                            .addComponent(_parButton, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
                            .addComponent(_xButton, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
                            .addComponent(_elevateButton, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(_costButton, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                            .addComponent(_logButton, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                            .addComponent(_parclosedButton, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                            .addComponent(_pigrecoButton, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(_sinButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(_cosButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(_tgButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(_cotgButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(67, 67, 67))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_Normale)
                    .addComponent(_Integrale)
                    .addComponent(_Derivata))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_1Button)
                    .addComponent(_2Button)
                    .addComponent(_3Button)
                    .addComponent(_piuButton)
                    .addComponent(_parButton)
                    .addComponent(_parclosedButton)
                    .addComponent(_sinButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_4Button)
                    .addComponent(_5Button)
                    .addComponent(_6Button)
                    .addComponent(_menoButton)
                    .addComponent(_xButton)
                    .addComponent(_cosButton)
                    .addComponent(_costButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_7Button)
                    .addComponent(_perButton)
                    .addComponent(_elevateButton)
                    .addComponent(_8Button)
                    .addComponent(_9Button)
                    .addComponent(_tgButton)
                    .addComponent(_pigrecoButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(_divButton)
                    .addComponent(_expButton)
                    .addComponent(_logButton)
                    .addComponent(_0Button)
                    .addComponent(_virgButton)
                    .addComponent(_cotgButton))
                .addGap(18, 18, 18)
                .addComponent(_calcolaButton)
                .addGap(29, 29, 29))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void _menoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__menoButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("-"));
}//GEN-LAST:event__menoButtonActionPerformed

    private void _virgButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__virgButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat(","));
}//GEN-LAST:event__virgButtonActionPerformed

    private void _costButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__costButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("a"));
}//GEN-LAST:event__costButtonActionPerformed

    private void _piuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__piuButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("+"));
}//GEN-LAST:event__piuButtonActionPerformed

    private void _xButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__xButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("x"));
}//GEN-LAST:event__xButtonActionPerformed

    private void _elevateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__elevateButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("^"));
}//GEN-LAST:event__elevateButtonActionPerformed

    private void _0ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__0ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("0"));
}//GEN-LAST:event__0ButtonActionPerformed

    private void _8ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__8ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("8"));
}//GEN-LAST:event__8ButtonActionPerformed

    private void _9ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__9ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("9"));
}//GEN-LAST:event__9ButtonActionPerformed

    private void _pigrecoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__pigrecoButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("3,1415"));
}//GEN-LAST:event__pigrecoButtonActionPerformed

    private void _6ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__6ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("6"));
}//GEN-LAST:event__6ButtonActionPerformed

    private void _7ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__7ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("7"));
}//GEN-LAST:event__7ButtonActionPerformed

    private void _divButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__divButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("/"));
}//GEN-LAST:event__divButtonActionPerformed

    private void _perButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__perButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("*"));
}//GEN-LAST:event__perButtonActionPerformed

    private void _parButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__parButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("("));
}//GEN-LAST:event__parButtonActionPerformed

    private void _parclosedButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__parclosedButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat(")"));
}//GEN-LAST:event__parclosedButtonActionPerformed

    private void _sinButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__sinButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("sin"));
}//GEN-LAST:event__sinButtonActionPerformed

    private void _cosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__cosButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("cos"));
}//GEN-LAST:event__cosButtonActionPerformed

    private void _tgButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__tgButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("tg"));
}//GEN-LAST:event__tgButtonActionPerformed

    private void _cotgButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__cotgButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("cotg"));
}//GEN-LAST:event__cotgButtonActionPerformed

    private void _logButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__logButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("log"));
}//GEN-LAST:event__logButtonActionPerformed

    private void _5ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__5ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("5"));
}//GEN-LAST:event__5ButtonActionPerformed

    private void _expButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__expButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("exp"));
}//GEN-LAST:event__expButtonActionPerformed

    private void _2ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__2ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("2"));
}//GEN-LAST:event__2ButtonActionPerformed

    private void _1ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__1ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("1"));
}//GEN-LAST:event__1ButtonActionPerformed

    private void _4ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__4ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("4"));
}//GEN-LAST:event__4ButtonActionPerformed

    private void _3ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__3ButtonActionPerformed
        _TextBox.setText(_TextBox.getText().concat("3"));
}//GEN-LAST:event__3ButtonActionPerformed

    private void _NormaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__NormaleActionPerformed
        CalcoloNormale();
        setType(type.NORMALE);
    }//GEN-LAST:event__NormaleActionPerformed

    private void _IntegraleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__IntegraleActionPerformed
        Attiva();
        setType(type.INTEGRALE);
    }//GEN-LAST:event__IntegraleActionPerformed

    private void _DerivataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__DerivataActionPerformed
        Attiva();
        setType(type.DERIVATA);
    }//GEN-LAST:event__DerivataActionPerformed

    private void _calcolaButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__calcolaButtonActionPerformed
        Type t = getType();
        switch(t){
            case NORMALE:
                _TextBox.setText(calc.Calcola(_TextBox.getText()));
                break;
            case DERIVATA:
                _TextBox.setText(calc.CalcolaDerivata(_TextBox.getText()));
                break;
            case INTEGRALE:
                _TextBox.setText(calc.CalcolaIntegrale(_TextBox.getText()));
                break;
        }
    }//GEN-LAST:event__calcolaButtonActionPerformed

    private void CalcoloNormale()
    {
        this._cosButton.setEnabled(false);
        this._costButton.setEnabled(false);
        this._cotgButton.setEnabled(false);
        this._elevateButton.setEnabled(false);
        this._expButton.setEnabled(false);
        this._logButton.setEnabled(false);
        this._sinButton.setEnabled(false);
        this._tgButton.setEnabled(false);
        this._pigrecoButton.setEnabled(false);
        this._virgButton.setEnabled(false);
        this._xButton.setEnabled(false);
    }
    private void Attiva(){
        this._cosButton.setEnabled(true);
        this._costButton.setEnabled(true);
        this._cotgButton.setEnabled(true);
        this._elevateButton.setEnabled(true);
        this._expButton.setEnabled(true);
        this._logButton.setEnabled(true);
        this._sinButton.setEnabled(true);
        this._tgButton.setEnabled(true);
        this._pigrecoButton.setEnabled(true);
        this._virgButton.setEnabled(true);
        this._xButton.setEnabled(true);
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Calcolatrice().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton _0Button;
    private javax.swing.JButton _1Button;
    private javax.swing.JButton _2Button;
    private javax.swing.JButton _3Button;
    private javax.swing.JButton _4Button;
    private javax.swing.JButton _5Button;
    private javax.swing.JButton _6Button;
    private javax.swing.JButton _7Button;
    private javax.swing.JButton _8Button;
    private javax.swing.JButton _9Button;
    private javax.swing.JRadioButton _Derivata;
    private javax.swing.JRadioButton _Integrale;
    private javax.swing.JRadioButton _Normale;
    private javax.swing.JTextArea _TextBox;
    private javax.swing.JButton _calcolaButton;
    private javax.swing.JButton _cosButton;
    private javax.swing.JButton _costButton;
    private javax.swing.JButton _cotgButton;
    private javax.swing.JButton _divButton;
    private javax.swing.JButton _elevateButton;
    private javax.swing.JButton _expButton;
    private javax.swing.JButton _logButton;
    private javax.swing.JButton _menoButton;
    private javax.swing.JButton _parButton;
    private javax.swing.JButton _parclosedButton;
    private javax.swing.JButton _perButton;
    private javax.swing.JButton _pigrecoButton;
    private javax.swing.JButton _piuButton;
    private javax.swing.JButton _sinButton;
    private javax.swing.JButton _tgButton;
    private javax.swing.JButton _virgButton;
    private javax.swing.JButton _xButton;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
